<template>
	<keep-alive>
		<component :is="currentComponent" :data="resource.data"></component>
	</keep-alive>
</template>

<script lang="ts" setup>
	import {
		ref,
		markRaw,
		onMounted,
		reactive
	} from 'vue'
	import Card from '_c/card/Card.vue'
	import router from '@/router'
	import {
		getTopic
	} from '@/api/common'

	const resource = reactive({
		"data": []
	})


	const currentComponent = ref(null)

	onMounted(() => {
		getData()
	})

	function getData() {
		currentComponent.value = markRaw(Card)
		getTopic()
			.then(res => {
				if (res.code != 0) {
					console.log(`获取数据失败，` + res.message);
				} else {
					resource.data = res.data
				}
			}).catch(err => {
				console.log("出错了~", err)
			})
	}
	
</script>

<style>
</style>
